package com.matchmaking.system.aop;

import cn.hutool.log.Log;
import com.matchmaking.system.service.SysDictDataService;
import com.matchmaking.system.service.SysDictTypeService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;


@Aspect
@Component
@Slf4j
public class MyAop {

    @Autowired
    HttpServletRequest request;

    @Autowired
    SysDictTypeService dictTypeService;

    @Autowired
    SysDictDataService dictDataService;

    @Around(value = "execution( * com.matchmaking.system.controller.*.*(..))")
    public Object aop(ProceedingJoinPoint joinPoint) throws Throwable {
        String method = request.getMethod();//获取请求方法
        String remoteAddr = request.getRemoteAddr();//获取请求ip地址
        String requestURI = request.getRequestURI();//获取请求路径
        Date date = new Date();//获取当前为时间
        //打印
        log.debug("方法名:" + method);
        log.debug("请求地址:" + remoteAddr);
        log.debug("请求路径:" + requestURI);
        log.debug("当前时间:" + date);
        return joinPoint.proceed();
    }

}
